package com.marvels.common.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import com.github.pagehelper.PageInfo;
/**
 * 转换为前端需要的dto结构
 * @author zhaosa
 *
 */
public class PageConverter {

	public static Map<String,Object> converter(PageInfo<?> pageInfo){
		Map<String,Object> result = new HashMap<String,Object>();
		result.put("prePage", pageInfo.getPrePage());
		result.put("endRow", pageInfo.getEndRow());
		result.put("slider", new ArrayList<Integer>());
		result.put("limit", pageInfo.getPageSize());
		result.put("lastPage", pageInfo.isIsLastPage());
		result.put("nextPage", pageInfo.getNextPage());
		result.put("hasNextPage", pageInfo.isHasNextPage());
		result.put("items", pageInfo.getList());
		result.put("page", pageInfo.getPageNum());
		result.put("totalCount", pageInfo.getTotal());
		result.put("hasPrePage", pageInfo.isHasPreviousPage());
		result.put("startRow", pageInfo.getStartRow());
		result.put("firstPage", pageInfo.isIsFirstPage());
		result.put("offset", 0);
		result.put("totalPages", pageInfo.getPages());
		return result;
	}
	
}
